#!/bin/env bash

PID=`ps -ef |grep 'yilan-chat-server-app.jar' |grep -v grep | awk '{print $2}'`
if [ ! "$PID" ]
then # 这里判断TOMCAT进程是否存在
 echo $PID"进程不存在"
else
 echo "进程存在 杀死进程PID$PID"
 kill -9 $PID
fi
 nohup java -Xms256m -Xmx256m -server -XX:+HeapDumpOnOutOfMemoryError -jar 'yilan-chat-server-app.jar'  --spring.profiles.active=dev >yilan-chat-server.log &
#根据重启后是否有当前应用判断启动是否成功
pid=$(ps -ef | grep java| grep 'yilan-chat-server-app.jar'|awk -F '[ ]+' '{print $2}')
echo $pid
if [ -z $pid ]
then
 echo "启动失败"
 exit 1
else
 echo 'yilan-chat-server-app.jar' : $pid "启动成功"
fi